package Models;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

/**
 * @author Morten
 */
public class Sale
{
	private static int nextId = 100;
	private int id;
	private double total = 0d;
	private Date date;
	private Customer customer;
	private ArrayList<Item> items = new ArrayList<Item>();
	private Employee employee;
	private boolean delivery, delivered = false, paid = false, activated = true;

	public Sale(Customer customer, Employee employee)
	{
		this.setCustomer(customer);
		this.setEmployee(employee);
		this.setDate(Calendar.getInstance().getTime());
		this.id = Sale.nextId;
		Sale.nextId++;
	}

	public void addItem(Item item)
	{
		this.items.add(item);
		this.total += item.getPrice();
		item.takeOne();
	}

	public void pay()
	{
		this.setPaid(true);
	}

	public Customer getCustomer()
	{
		return customer;
	}

	public Date getDate()
	{
		return date;
	}

	public boolean isDelivered()
	{
		return delivered;
	}

	public boolean isDelivery()
	{
		return delivery;
	}

	public Employee getEmployee()
	{
		return employee;
	}

	public int getId()
	{
		return id;
	}

	public ArrayList<Item> getItems()
	{
		return items;
	}

	public boolean isPaid()
	{
		return paid;
	}

	public double getTotal()
	{
		return total;
	}

	public boolean isActivated()
	{
		return activated;
	}

	public void setActivated(boolean activated)
	{
		this.activated = activated;
	}

	public void setCustomer(Customer customer)
	{
		this.customer = customer;
	}

	public void setDate(Date date)
	{
		this.date = date;
	}

	public void setDelivered(boolean delivered)
	{
		this.delivered = delivered;
	}

	public void setDelivery(boolean delivery)
	{
		this.delivery = delivery;
	}

	public void setEmployee(Employee employee)
	{
		this.employee = employee;
	}

	public void setItems(ArrayList<Item> items)
	{
		this.items = items;
	}

	public void setPaid(boolean paid)
	{
		this.paid = paid;
	}

	public void setTotal(double total)
	{
		this.total = total;
	}
}
